<template>
  <div>
    <el-descriptions border :column="1" title="文章详情">
      <template slot="extra">
        <el-button type="primary" size="small">编辑</el-button>
        <el-button type="danger" size="small">删除</el-button>
      </template>
      <el-descriptions-item label="id">{{ article.id }}</el-descriptions-item>
      <el-descriptions-item label="标题">{{
        article.title
      }}</el-descriptions-item>
      <el-descriptions-item label="作者">{{
        article.author
      }}</el-descriptions-item>
    </el-descriptions>
  </div>
</template>

<script>
export default {
  data() {
    return {
      article: {},
    };
  },
  created() {
    const { id } = this.$route.params;
    const loading = this.$loading({
      lock: true,
      text: "Loading",
      spinner: "el-icon-loading",
      background: "rgba(0, 0, 0, 0.7)",
    });
    this.$store
      .dispatch("article/getArticleAction", id)
      .then((res) => {
        // console.log(res.data);
        this.article = res.data;
      })
      .finally(() => {
        loading.close();
      });
  },
};
</script>
